package com.app.backend.password.check.config;

import com.app.backend.password.check.filter.HttpServletRequestWrapperFilter;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;

/**
 * @author: ZhengJunJie
 * @Date: 2020/6/12 17:44
 */
@EnableConfigurationProperties(PasswordCheckProperties.class)
@Configuration
public class PasswordCheckConfiguration {

    private static final int FIRST_ORDER = 1;

    @Bean
    public FilterRegistrationBean setFilter() {
        FilterRegistrationBean filterRegistrationBean = new FilterRegistrationBean();
        filterRegistrationBean.setFilter(new HttpServletRequestWrapperFilter());
        filterRegistrationBean.addUrlPatterns("/*");
        //order的数值越小，在所有的filter中优先级越高
        filterRegistrationBean.setOrder(FIRST_ORDER);
        return filterRegistrationBean;
    }

}
